@import "./variables";
// reset
* {
  box-sizing: border-box;
  outline: none;
}

html {
  font-size: 13px;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.2em;
  background-color: #f1f1f1;
  -webkit-font-smoothing: antialiased;
}

a {
  color: #999;
}

p {
  line-height: 1.5em;
}

// color
@each $colorKey, $color in $colors {
  .text-#{$colorKey} {
    color: $color;
  }

  .bg-#{$colorKey} {
    background-color: $color;
  }
}

// text overflow
.text-ellipsis {
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

// text align
@each $var in (left, center, right) {
  .text-#{$var} {
    text-align: $var !important;
  }
}

// font size
@each $sizeKey, $size in $font-sizes {
  .fs-#{$sizeKey} {
    font-size: $size * $base-font-size;
  }
}

// width height
.w-100 {
  width: 100%;
}
.h-100 {
  height: 100%;
}

// flex
.d-flex {
  display: flex;
}
.flex-column {
  flex-direction: column;
}
.flex-wrap {
  flex-wrap: wrap;
}
.flex-1 {
  flex: 1;
}
.flex-grow-1 {
  flex-grow: 1;
}

@each $key, $value in $flex-jc {
  .jc-#{$key} {
    justify-content: $value;
  }
}

@each $key, $value in $flex-ai {
  .ai-#{$key} {
    align-items: $value;
  }
}

// spacing
@each $typeKey, $type in $spacing-types {
  // m-1 => margin: 1rem
  @each $sizeKey, $size in $spacing-size {
    .#{$typeKey}-#{$sizeKey} {
      #{$type}: $size * $spacing-base-size;
    }
    // mx-1 x轴
    .#{$typeKey}x-#{$sizeKey} {
      #{$type}-left: $size * $spacing-base-size;
      #{$type}-right: $size * $spacing-base-size;
    }
    // my-1 y轴
    .#{$typeKey}y-#{$sizeKey} {
      #{$type}-top: $size * $spacing-base-size;
      #{$type}-bottom: $size * $spacing-base-size;
    }
  }

  // mt-1 => margin-top: 1rem
  @each $directionKey, $direction in $spacing-directions {
    @each $sizeKey, $size in $spacing-size {
      .#{$typeKey}#{$directionKey}-#{$sizeKey} {
        #{$type}-#{$direction}: $size * $spacing-base-size;
      }
    }
  }
}

// button
.btn {
  border: none;
  border-radius: 0.1538rem;
  font-size: map-get($font-sizes, "sm") * $base-font-size;
  // padding: 4px 6px;
  padding: 0.4rem 0.7rem;
}

// nav
.nav {
  display: flex;
  .nav-item {
    border-bottom: 3px solid transparent;
    padding-bottom: 0.2rem;
    // & 表示上层本身
    &.active {
      color: map-get($colors, "primary");
      border-bottom-color: map-get($colors, "primary");
    }
  }
  &.nav-inverse {
    .nav-item {
      color: map-get($colors, "white");
      &.active {
        border-bottom-color: map-get($colors, "white");
      }
    }
  }
}

// sprite
.sprite {
  background: url(../images/index.png) no-repeat 0 0;
  background-size: 28.8462rem;
  display: inline-block;
  &.sprite-news {
    width: 1.7692rem;
    height: 1.5385rem;
    background-position: 63.546% 15.517%;
  }
  &.sprite-stories {
    width: 1.769231rem;
    height: 1.538462rem;
    background-position: 90.483% 15.614%;
  }
  &.sprite-shops {
    width: 1.461538rem;
    height: 1.692308rem;
    background-position: 36.746% 0.924%;
  }
  &.sprite-tiyan {
    width: 1.538462rem;
    height: 1.538462rem;
    background-position: 10.408% 15.517%;
  }
  &.sprite-new_person {
    width: 1.538462rem;
    height: 1.5rem;
    background-position: 89.733% 1.266%;
  }
  &.sprite-glory {
    width: 1.846154rem;
    height: 1.5385rem;
    background-position: 36.467% 15.287%;
  }
  &.sprite-camp {
    width: 1.846154rem;
    height: 1.846154rem;
    background-position: 63.3% 0.927%;
  }
  &.sprite-public {
    width: 1.846154rem;
    height: 1.538462rem;
    background-position: 0 96.207%;
  }
  &.sprite-edition {
    height: 25px;
    width: 25px;
    background-size: 100% 100%;
    background: url(../icons/version-icon.png);
  }
  &.sprite-env {
    height: 25px;
    width: 34px;
    background-size: 100% 100%;
    background: url(../icons/djhj.png) no-repeat;
  }
  &.sprite-plan {
    height: 25px;
    width: 25px;
    background-size: 100% 100%;
    background: url(../icons/ipgc.png);
  }
  &.sprite-interactive {
    height: 25px;
    width: 25px;
    background-size: 100% 100%;
    background: url(../icons/cyhdy.png);
  }
}

// borders
@each $dir in (top, right, bottom, left) {
  .border-#{$dir} {
    border-#{$dir}: 1px solid $border-color
  }
}
